<template>
	<div>
		<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
		<div style="padding: 20px;">
		<!--	成绩明细页面(改完字段)-->
			<!--<div style="margin:5px 0px 0px 0px;background-color: #f5f5f5;padding: 20px;">
				<Row >
			        <Col span="24" style="text-align: left;">
						<span style="font-size: 18px;color: #1a1a1a;font-weight: 540;">评价名称：{{excelname}}</span>
					</Col>
				</Row>
				<Row style="margin:15px 0px 0px 0px;color: #666666;">
			        <Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">年级：{{gradeName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">基数：{{baseExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">本次：{{thisExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">时间：{{createTime}}</span>
					</Col>
				</Row>
			</div>-->
			<Row >
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>科目筛选：</span>
		        	<RadioGroup  v-model="subjectselect" type="button" @on-change="changeselect">
		        		<Radio v-for="item in subjectlist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				       
				    </RadioGroup>
		        </Col>
		        <Spin size="large" fix v-if="subjectlistshow"></Spin>
		    </Row>
		    <Row >
		        <Col span="24" style="text-align: right;margin-bottom:10px;">
		        	<Button style="background-color: #4496fc;" size="small" :loading="loading" @click="exportexl">
		        		<span v-if="!loading"><img style="width: 20px;margin-top: 2px;" src="../../../../../../static/img/export.png" alt="" /></span>
				        <span v-else>加载中</span>
		        	</Button>
		        </Col>
		    </Row>
			<v-table :min-height='500' :is-loading="loadingShow" is-horizontal-resize is-vertical-resize style="width:100%;" :title-rows="titleRows" :columns="columns" :table-data="tableData" ></v-table>
		</div>
	</div>
</template>

<script>
	import api from "@/components/js/Apidomain.js"
	import { getsessionstorage } from '@/components/js/Localstorage'
	export default{
		data(){
			return{
//				excelname:"",			//查询的名字
//				gradeName:"",			//查询的年级
//				baseExamName:"",		//查询的基数考试名字
//				thisExamName:"",		//查询的本次考试名字
//				createTime:"",			//查询的评价时间
				
				loadingShow:false,				//表格获取的加载中显示隐藏
				
				loading: false,				//下载模板按钮上的加载中显示隐藏
				
				subjectlistshow:false,			//科目选择列表的加载中显示隐藏
				
				subjectselect:"",				//选择的科目
				subjectlist: [
//					{value: '1',label: '语文'},
//					{value: '2',label: '数学'},
//                  {value: '3',label: '英语'}, 
//                  {value: '4',label: '物理'},
//					{value: '5',label: '化学'},
//                  {value: '6',label: '生物'}, 
//                  {value: '7',label: '历史'},
//					{value: '8',label: '地理'},
//                  {value: '9',label: '政治'}, 
                ],
                
                
				titleRows: [
                            [
                             	{fields: ['classesNo'], title: '班级', titleAlign: 'center', rowspan: 2,colspan: 1},
	                            {fields: ['studentName'], title: '姓名', titleAlign: 'center', rowspan: 2,colspan: 1},
	                            {fields: ['baseExamResult','baseStanResult','baseHGrade','baseVGrade'], title: '基数成绩', titleAlign: 'center',colspan: 4},
	                            {fields: ['thisExamResult','thisStanResult','thisHGrade','thisVGrade'], title: '本次成绩', titleAlign: 'center',colspan: 4},
                              
                            ],
                            [	
                            	{fields: ['baseExamResult'], title: '原始分', titleAlign: 'center'},
                              	{fields: ['baseStanResult'], title: '标准分', titleAlign: 'center'},
                              	{fields: ['baseHGrade'], title: '横向', titleAlign: 'center'},
                              	{fields: ['baseVGrade'], title: '纵向', titleAlign: 'center'},
                              	{fields: ['thisExamResult'], title: '原始分', titleAlign: 'center'},
                              	{fields: ['thisStanResult'], title: '标准分', titleAlign: 'center'},
                              	{fields: ['thisHGrade'], title: '横向', titleAlign: 'center'},
                              	{fields: ['thisVGrade'], title: '纵向', titleAlign: 'center'},
                              	
                              	
                            ],
				],
				columns:[
                    		{field: 'classesNo', width: 80,  columnAlign: 'center',isResize:true},
                        	{field: 'studentName', width: 80,  columnAlign: 'center',isResize:true},
                          	{field: 'baseExamResult', width: 80,  columnAlign: 'center',isResize:true},
                          	{field: 'baseStanResult', width: 80,  columnAlign: 'center',isResize:true},
                          	{field: 'baseHGrade', width: 80,  columnAlign: 'center',isResize:true},
                          	{field: 'baseVGrade', width: 80,  columnAlign: 'center',isResize:true},
                          	{field: 'thisExamResult', width: 80,  columnAlign: 'center',isResize:true},
                          	{field: 'thisStanResult', width: 80,  columnAlign: 'center',isResize:true},
                        	{field: 'thisHGrade', width: 80,  columnAlign: 'center',isResize:true},
                        	{field: 'thisVGrade', width: 80,  columnAlign: 'center',isResize:true},
                ],
                tableData: [
//                      {"classesNo":"0101","studentName":"张三","baseExamResult":"8.1","baseStanResult":"8.0","baseHGrade":"5.0","baseVGrade":"2.0","thisExamResult":"10.0","thisStanResult":"10.2","thisHGrade":"8.0","thisVGrade":"3.0"},
//                      {"classesNo":"0102","studentName":"李四","baseExamResult":"8.1","baseStanResult":"8.0","baseHGrade":"5.0","baseVGrade":"2.0","thisExamResult":"10.0","thisStanResult":"10.2","thisHGrade":"8.0","thisVGrade":"3.0"},
//                      {"classesNo":"0103","studentName":"王五","baseExamResult":"8.1","baseStanResult":"8.0","baseHGrade":"5.0","baseVGrade":"2.0","thisExamResult":"10.0","thisStanResult":"10.2","thisHGrade":"8.0","thisVGrade":"3.0"},
//                      {"classesNo":"0104","studentName":"名字1","baseExamResult":"8.1","baseStanResult":"8.0","baseHGrade":"5.0","baseVGrade":"2.0","thisExamResult":"10.0","thisStanResult":"10.2","thisHGrade":"8.0","thisVGrade":"3.0"},
//                      {"classesNo":"0105","studentName":"名字2","baseExamResult":"8.1","baseStanResult":"8.0","baseHGrade":"5.0","baseVGrade":"2.0","thisExamResult":"10.0","thisStanResult":"10.2","thisHGrade":"8.0","thisVGrade":"3.0"},
//                      {"classesNo":"0106","studentName":"名字3","baseExamResult":"8.1","baseStanResult":"8.0","baseHGrade":"5.0","baseVGrade":"2.0","thisExamResult":"10.0","thisStanResult":"10.2","thisHGrade":"8.0","thisVGrade":"3.0"},
                      
                ],
			}
		},
		created(){
//			this.excelname = getsessionstorage('excelname')
//			this.gradeName = getsessionstorage('gradeName')
//			this.baseExamName = getsessionstorage('baseExamName')
//			this.thisExamName = getsessionstorage('thisExamName')
//			this.createTime = getsessionstorage('createTime')
			this.getsubjectlist()
		},
		computed: {
			
		},
		methods:{
			changeselect:function(){
//				//console.log(this.subjectselect)
				this.gettablelist();
			},
			getsubjectlist:function(){
           		this.subjectlistshow = true;
           		let sessionroleid = getsessionstorage('roleid');
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaPerformance/getSubjectByAd/'+sessionroleid;
            	this.$http.post(url, {}).then(function(response) {
					if(response.data.success == true){
						
//						////console.log(response.data.data)
						self.subjectlist = response.data.data
						if(self.subjectlist.length != 0){
							self.subjectselect = self.subjectlist[0].value;
							self.gettablelist();
						}
						
						
						self.subjectlistshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            		self.subjectlistshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00148',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
           	},
           	gettablelist:function(){
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId')
				if(sessionroleid && sessionperformId){
					this.loadingShow = true;
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaStudentDetail/listDto/'+this.subjectselect+'/'+sessionperformId+'/'+sessionroleid;
	            	this.$http.post(url).then(function(response) {
						if(response.data.success == true){
							
//		            		////console.log(response.data.data)
							self.tableData = response.data.data
							self.loadingShow = false;
			            }else if(response.data.success == false){
			            		self.loadingShow = false;
			            		self.$Message.error({
									content: response.data.msg,
									duration: 10,
									closable: true
								});
			            	}
			            })
						.catch(function(error) {
							self.loadingShow = false;
							self.$Message.error({
								content: '系统发生错误：错误码00149',
								duration: 10,
								closable: true
							});
						});
				}else{
					self.$Message.error({
							content: '系统发生错误：错误码00150',
							duration: 10,
							closable: true
						});
				}
			},
			exportexl:function(){
			
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				let subject = this.subjectselect;
				if(sessionroleid && sessionperformId){
					this.loading = true;
				
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaStudentDetail/exportExcelDto/'+subject+'/'+sessionperformId+'/'+sessionroleid;
	            	this.$http.post(url).then(function(response) {
						if(response.data.success == true){
	//						////console.log(response.data.data)
							window.location.href = response.data.data;
							self.loading = false;
		            }else if(response.data.success == false){
		            		self.loading = false;
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
		            	
					})
					.catch(function(error) {
						self.loading = false;
						self.$Message.error({
							content: '系统发生错误：错误码00151',
							duration: 10,
							closable: true
						});
					});
				}
			}  
		}
	}
</script>

<style>
</style>